//
// Created by Administrator on 2021/11/23.
// May Saint Diana bless you!
//
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <climits>

using namespace std;

class Solution {
public:
    bool checkZeroOnes(string s) {
        return countContiguousChar(s, '1') > countContiguousChar(s, '0');
    }

    /*
     * 统计在s中出现的连续字符targer的最大长度
     */
    int countContiguousChar(string &s, char target) {
        int maxLength = 0;
        int contiguousLength = 0;
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] == target) {
                // 这一位是目标 看前一位
                if (i == 0 || s[i - 1] != target) {
                    contiguousLength = 1;
                } else {
                    ++contiguousLength;
                }
                maxLength = max(maxLength, contiguousLength);
            } else {
                contiguousLength = 0;
            }
        }
        return maxLength;
    }
};

int main() {
    Solution s;
    cout << s.checkZeroOnes("1101") << endl;
    cout << s.checkZeroOnes("111000") << endl;
    return 0;
}
